package com.qikux.dao.impl;

import com.qikux.dao.UserScoreDao;
import com.qikux.entity.ScoreConfig;
import com.qikux.entity.UserScore;
import org.haredot.annotation.Repository;
import org.haredot.utils.DBUtils;

@Repository
public class UserScoreDaoImpl implements UserScoreDao {

    @Override
    public ScoreConfig findScoreConfigByAction(String action) {
        String sql = "select * from tb_score_config where action = ? and state = 1 and del = 0" ;
        return DBUtils.query(sql, ScoreConfig.class, action);
    }

    @Override
    public int saveUserScore(UserScore userScore) {
        String sql = "insert into tb_user_score(action, score, res_id, user_id, create_time) values(#{action}, #{score}, #{resId}, #{userId}, now())" ;
        return DBUtils.update(userScore, sql);
    }
}
